package com.链表;

/**
 * 移出连表中给出的节点
 */
public class 移除链表元素 {
    public static ListNode removeElements(ListNode head, int val) {
      ListNode domac = new ListNode(-1);
      domac.next = head;
      ListNode curr = domac;
      while(curr.next != null){
          if(curr.next.val == val){
              curr.next = curr.next.next;
          }else{
              curr = curr.next;
          }
      }
      return domac.next;


    }

    public static void main(String[] args) {
        ListNode l1 = new ListNode(new int[]{1,2,3,3});
        System.out.println(removeElements(l1,3));
    }


}
